package com.zhongxi.guoyuan.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.zhongxi.guoyuan.entity.projectItem.ProjectItemData;
import com.zhongxi.guoyuan.fragment.sliding.RewardCoinSlidingFragment;

import java.util.List;

/**
 * Created by Administrator on 2016/10/28.
 */

public class SlidingAdapter extends FragmentPagerAdapter {

    private final List<ProjectItemData> TITLES;
    private int type;
    Fragment fragment = null;

    public SlidingAdapter(FragmentManager fm, List<ProjectItemData> TITLES, int type) {
        super(fm);
        this.TITLES = TITLES;
        this.type = type;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TITLES.get(position).getName();
    }

    @Override
    public int getCount() {
        return TITLES == null ? 0 : TITLES.size();
    }

    @Override
    public Fragment getItem(int position) {
        switch (type) {
            case 0:
                break;
            case 1:
                fragment = new RewardCoinSlidingFragment(TITLES.get(position).getId());
                break;
        }
        return fragment;
    }

    public void loadRewardCoinMore() {
        ((RewardCoinSlidingFragment) fragment).loadMore();
    }

}
